import Vue from 'vue'
import Router from 'vue-router'
/* Layout */
// import Layout from '../layout/index'
import Light from "../components/Light";
import Trolley from "../components/Trolley";
import Test from "../components/Test";
import Phone from "../components/Phone";
import PlayMusic from "../components/PlayMusic";
/**
 * 解决重复点击路由报错问题
 */
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

/**
 * 配置全局的路由
 * children嵌套的子路由
 * 将children的组件显示在AppMain的<router-view :key="key"/>位置
 */
// 公共路由
export const constantRoutes = [
    {
        path: '/',
        name: "Light",
        component: Light,
    },
    {
        path: '/light',
        name: "Light",
        component: Light,
    },
    {
        path: '/trolley',
        name: "Trolley",
        component: Trolley,
    },
    {
        path: '/test',
        name: "Test",
        component: Test,
    },
    {
        path: '/phone',
        name: "Phone",
        component: Phone,
    },
    {
        path: '/playMusic',
        name: "PlayMusic",
        component: PlayMusic,
    }
];

export default new Router({
    mode: 'history', // 去掉url中的#
    scrollBehavior: () => ({y: 0}),
    routes: constantRoutes
})

